package cn.itsource.org.service.impl;

import cn.itsource.base.service.impl.BaseServiceImpl;
import cn.itsource.org.domain.Employee;
import cn.itsource.org.domain.Shop;
import cn.itsource.org.mapper.EmployeeMapper;
import cn.itsource.org.mapper.ShopMapper;
import cn.itsource.org.service.IEmployeeService;
import cn.itsource.org.service.IShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

@Service
@Transactional(propagation = Propagation.SUPPORTS,readOnly = true)
public class ShopServiceImpl extends BaseServiceImpl<Shop> implements IShopService {

    @Autowired
    private EmployeeMapper employeeMapper;
    @Autowired
    private ShopMapper shopMapper;
    //店铺入驻
    @Override
    public void settlement(Shop shop) {
        //1.校验 用户的手机号是否注册过

        //补全信息
        shop.setRegisterTime(new Date());
        shop.setState(0);
        shop.getAdmin().setState(0);
        //2.保存用户信息 返回主键
        employeeMapper.save(shop.getAdmin());
        //3.保存店铺信息
        shopMapper.save(shop);


    }
}
